/**
 * 
 */

var action = 0; 

$(document).ready(function(){
	
	$("#settings").click( function() {
		loadView();
	});
	
	$("#home").click( function() {
		loadHome();
	});
	
	$("#back").click( function() {
		loadBack();
	});
	
});

function loadView() {
	action = 0;

	$.ajax({
		url : "views/menu.html",
		cache : false,
		success : function(html) {
			$("#screen").html(html);
			reloadEvents();
		}
	});
}

function loadHome() {
	action = 0;

	$.ajax({
		url : "views/home.html",
		cache : false,
		success : function(html) {
			$("#screen").html(html);
			reloadEvents();
		}
	});
}

function loadChannel() {

	$.ajax({
		url : "views/channel.html",
		cache : false,
		success : function(html) {
			$("#screen").html(html);
			reloadEvents();
		}
	});
}

function loadSettings(setting) {
	action = 1;

	$.ajax({
		url : "views/channel.html",
		cache : false,
		success : function(html) {
			$("#screen").html(html);
			$("#settingsImage").css("background-image", "url(images/" + setting + ")"); 
		}
	});
}

function loadShortcut(shortcut) {
	action = 2;

	$.ajax({
		url : "views/shortcut.html",
		cache : false,
		success : function(html) {
			$("#screen").html(html);
			$("#shortcutImage").css("background-image", "url(images/" + shortcut + ")"); 
		}
	});
}

function loadBack() {
	
	if(action == 1) {
		loadView();
	} else if(action == 2){
		loadHome();
	} else {
		$("#screen").html("");
	}
}